package com.lin.carbon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lin.carbon.entity.SysDict;
import com.lin.carbon.mapper.SysDictMapper;
import com.lin.carbon.service.SysDictService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
@Service
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {

    @Override
    public boolean addSysDict(SysDict sysDict) {
        // 设置创建时间和更新时间
        sysDict.setCreatedTime(LocalDateTime.now());
        sysDict.setUpdatedTime(LocalDateTime.now());
        return save(sysDict);
    }

    //更新字典信息
    @Override
    public boolean updateSysDict(SysDict sysDict) {
        return this.updateById(sysDict);
    }

    @Override
    public boolean deleteSysDict(Long id) {
        UpdateWrapper<SysDict> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set("del_flag", 1) // 将 delFlag 设为 1 表示已删除
                .eq("id", id);
        return this.update(updateWrapper);
    }




}
